//
//  CGFloat_Ex.swift
//  Test
//
//  Created by cuicheng on 2021/8/26.
//

import UIKit

extension Int {
    var adapter: CGFloat {
        
        if UIScreen.main.bounds.width > UIScreen.main.bounds.height {
            return h
        }
        return w
    }
    
    var w: CGFloat {
        return CGFloat(self) * (UIScreen.main.bounds.width/UIRectUtil.designWidth)
    }
    
    var h: CGFloat {
        return CGFloat(self) * (UIScreen.main.bounds.height/UIRectUtil.designHeight)
    }
    
    var stringValue: String {
        return NSDecimalNumber(value: self).stringValue
    }
}

extension Double {
    
    var adapter: CGFloat {
        return CGFloat(self) * (UIScreen.main.bounds.width/UIRectUtil.designWidth)
    }
    
    var h: CGFloat {
        return CGFloat(self) * (UIScreen.main.bounds.height/UIRectUtil.designHeight)
    }
    
    var stringValue: String {
        return NSDecimalNumber(value: self).stringValue
    }
}

extension CGFloat {
    
    var max: CGFloat {
        return CGFloat.greatestFiniteMagnitude
    }
    
    var min: CGFloat {
        return CGFloat.leastNonzeroMagnitude
    }
}

extension String {
    var doubleValue: Double? {
        return Double(self)
    }
    var intValue: Int? {
        return Int(self)
    }
}
